package com.eudon.design_pattern.behavioral.memento;

import java.io.IOException;
import java.util.Scanner;

/**
 * @author eudon
 * @description 使用示例
 * @date 2025/9/3
 * @email syd19970616@gmail.com
 * @address <a href="https://gitee.com/eudon">Gitee</a>
 */
public class Use {
    public static void main(String[] args) throws IOException {
        InputText inputText = new InputText();
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String text = scanner.next();
            if ("all".equals(text)) {
                System.out.println(inputText.text());
            } else if ("undo".equals(text)) {
                System.out.println(inputText.restore());
            } else {
                inputText.append(text);
            }
        }
    }
}
